using JT808Protocol.Common;
using System;
using System.Text.Json.Serialization;

namespace JT808Protocol.Models.BodyParserStrategy.Location.LocationAddition
{
    /// <summary>
    /// 油量，DWORD，1/10L，对应车上油量表读数
    /// </summary>
    public class LaOilMass_0x02 : ILocationAddition
    {
        /// <summary>
        /// 油量,0.1升
        /// </summary>
        [JsonPropertyName("油量(0.1升)")] public ushort OilMass { get; set; }

        public override ILocationAddition ReadEntity(ReadOnlySpan<byte> source, int startIndex)
        {
            DataLength = (byte)(source[startIndex + 1] + 2);
            if (DataLength != 2 + 2)
            {
                //Logger.Warn($"位置附加信息的油量信息长度错误，略过解析");
                return null;
            }
            OilMass = ParseHelper.Uint16(ref source, startIndex + 2);

            return this;
        }
    }
}